<!DOCTYPE html>
<html>

<head>
    <meta content="telephone=no" name="format-detection">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta http-equiv="Content-Language" content="zh-CN">
    <meta http-equiv="x-ua-compatible" content="IE=edge, chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <meta name="renderer" content="webkit">
    <meta name="keywords" content="关键词" />
    <meta name="description" content="页面简介" />
    <link rel="icon" href="favicon.ico" />
    <link rel="shortcut icon" href="favicon.ico" />
    <link href="csaa/css/style.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" href="./csaa/fonts/iconfont/iconfont.css">
    <link rel="stylesheet" href="./csaa/fonts/materialicons/material-icons.css">

    <script language="javascript" type="text/javascript" src="./csaa/js/jquery.min.js"></script>
    <script src="./csaa/js/httpPath.js"></script>
    <script src="./csaa/js/httpUtils.js"></script>
    <script language="javascript" type="text/javascript" src="./csaa/js/site.js"></script>
    <title>全国青少年航空科学素质等级考试</title>
</head>

<body>
    <!-- 头部 开始 -->
    <div class="header">

    </div>
    <!-- 头部 结束 -->


    <!-- 内页banner 开始 -->
    <div class="in_banner">
        <div class="in_banner_box" style="background-image: url(./demo/img/banner01.jpg)
	"></div>
        <div class="text">考点分布</div>
    </div>
    <!-- 内页banner 开始 -->

    <!-- 主体 开始 -->
    <div id="outlets_main">
        <!-- 置顶区 开始 -->
        <div id="" class="main_top">
            <a id="btn_filterstore_show" class="btn btn_filterstore_show"><i class="material-icons">&#xe8b6;</i></a>
            <div class="filterstore_form">
                <form>
                    <div class="btn_close_wrap"><a class="btn_close btn"><i class="material-icons">&#xe5cd;</i><span>关闭</span></a></div>
                    <span class="label">查找考点</span>
                    <select name="province" class="form_input" id="province">
			  <!-- <option value="0">请选择省份</option> -->
			</select>
                    <select name="city" class="form_input" id="city">
			  <!-- <option value="0">请选择城市</option> -->
			</select>
                    <select name="area" class="form_input" id="area">
			  <!-- <option value="0">请选择区</option> -->
			</select>
                    <input type="text" class="form_input" name="keyword" placeholder="关键词" value="" id="search_input">
                    <input type="submit" class="btn_search btn btn_color_1 btn_shadow" value="搜索">
                </form>
            </div>

        </div>
        <!-- 置顶区 结束 -->
        <!-- 考点分布页面主体 开始 -->
        <div id="storemap_main" style="display: none;">

            <div class="storemap_wrap">
                <div id="storemap_list">
                    <div class="list_store">
                    </div>
                    <a class="main_more">暂无内容</a>
                </div>
                <div id="storemap_map">

                </div>
            </div>

        </div>
        <!-- 考点分布页面主体 结束 -->

        <!-- 考点列表项模板 开始 -->
        <div id="tmp_item_letstore" style="display: none;">
            <div class="item_letstore card">
                <a class="item_letstore_box">
                    <div class="name item_letstore_param"><span></span></div>
                    <div class="address item_letstore_param"><span></span></div>
                    <div class="phone_wrap">
                        <div class="phone item_letstore_param"><span></span></div>
                    </div>
                    <!-- <div class="vipmark"></div> -->
                </a>
                <div class="btnbox">
                    <a class="btn_readmore btn btn_color_1 btn_shadow">详情</a>
                </div>
            </div>
        </div>
        <!-- 考点列表项模板 结束 -->
        <!-- footer 开始-->
        <div class="footer_wrap">
        </div>

        <script src="./csaa/js/geo.js?r=3"></script>
        <script src="https://api.map.baidu.com/api?v=3.0&ak=DaPovYeO1apmksvwBnp5N4OD"></script>
        <script>
            fun_islogin(true); //页面头部登录
            setup();

            function province_textshow() {
                var tmp_province = ($("#province").val() != "省份") ? $("#province").val() : "--";
                var tmp_city = ($("#city").val() != "地级市") ? $("#city").val() : "";
                var tmp_area = ($("#area").val() != "市、县级市、县") ? $("#area").val() : "";
            }




            //移动端展开搜索门店框
            $(document).on("click", "#btn_filterstore_show", function() {
                $(".filterstore_form").toggleClass("show");
            });
            $(document).on("click", ".filterstore_form .btn_close", function() {
                $(".filterstore_form").toggleClass("show");
            });

            //本页搜索
            $(document).on("submit", ".filterstore_form form", function(e) {
                console.log(11111)
                e.preventDefault();
                $("#storemap_list .main_more").data("page", 1).click();
            });

            //保证地图全屏显示
            $(window).on("resize", function() {
                var tmp_storemap_height = $(window).height() - ($(".main_top").offset().top + $(".main_top").outerHeight());
                $("#storemap_main .storemap_wrap").height(tmp_storemap_height);
            });

            $(window).trigger("resize");
            $("#storemap_main").show();

            //初始化百度地图
            var map = new BMap.Map("storemap_map");
            var point = new BMap.Point(116.404, 39.915);
            map.addControl(new BMap.NavigationControl());
            map.centerAndZoom(point, 10);
            map.enableScrollWheelZoom();

            //地图配色
            map.setMapStyle({
                styleJson: [{
                    "featureType": "all",
                    "elementType": "all",
                    "stylers": {
                        "lightness": 10,
                        "saturation": -100
                    }
                }]
            });

            var tmp_pointarr = new Array(); //收集地图内的坐标点，用于自动缩放

            //在地图中打点定位
            function fun_placemarker($tmp_item_letstore, showWindow) {

                if ($tmp_item_letstore.data("isplaced")) {
                    var infoWindow = $tmp_item_letstore.data("isplaced");
                    if (showWindow) {
                        infoWindow.marker.openInfoWindow(infoWindow.infoWindow);
                    }
                    return false;
                }

                var tmp_lat = $tmp_item_letstore.data("lat");
                var tmp_lng = $tmp_item_letstore.data("lng");
                var store_address = $tmp_item_letstore.data("address");
                var store_storeid = $tmp_item_letstore.data("storeid");
                var store_name = $tmp_item_letstore.data("name");
                //var store_cover = $tmp_item_letstore.data("cover");
                var store_phone = $tmp_item_letstore.data("phone");
                var store_phone2 = $tmp_item_letstore.data("phone2");
                var tmp_html = "";
                var point = new BMap.Point(tmp_lng, tmp_lat);
                tmp_pointarr.push(point);

                /*if( store_cover && $(window).width() > 800 ){
		tmp_html += "<div style=\"width:150px;height:90px;margin-bottom:5px;background-image:url("+ store_cover +");background-repeat:no-repeat;background-position:center;background-size:cover;\"></div>";
	  }*/
                tmp_html += "<div style=\"font-size:14px;font-weight:bold;\">" + store_name + "</div><hr>";
                tmp_html += "<div style=\"font-size:12px;\">地址：" + store_address + "</div>";
                //tmp_html += "<div style=\"font-size:12px;\">电话：" + store_phone + "</div>";
                if (store_phone2) {
                    tmp_html += "<div style=\"font-size:12px;\">电话：" + store_phone2 + "</div>";
                }
                // tmp_html += "<hr><div style=\"font-size:12px;\"><a style=\"color:#0081e6;\" href=\"./store_view.html?storeid="+ store_storeid +"\">查看详情</a></div>";

                var infoWindow = new BMap.InfoWindow(tmp_html, {
                    enableMessage: false
                });

                var myIcon = new BMap.Icon("./csaa/img/mappointer.png", new BMap.Size(40, 40), {
                    "imageSize": new BMap.Size(40, 40),
                    "infoWindowAnchor": new BMap.Size(20, 0)
                });

                var marker = new BMap.Marker(point, {
                    icon: myIcon
                });
                $tmp_item_letstore.data("isplaced", {
                    "infoWindow": infoWindow,
                    "marker": marker
                });

                map.addOverlay(marker);
                marker.addEventListener("click", function() {
                    this.openInfoWindow(infoWindow);
                });
                if (showWindow) {
                    marker.openInfoWindow(infoWindow);
                }
            }


            //点击考点列表项在地图中定位
            $(document).on("click", ".list_store .item_letstore_box", function() {
                var $tmp_item_letstore = $(this).closest(".item_letstore");
                fun_placemarker($tmp_item_letstore, true);
            });




            var scrollload = {};
            var pauseload = {};
            //载入列表
            var ajax_letstore_list;
            $("#storemap_list").on("click", ".main_more", function() {
                if (pauseload.letstore_list) {
                    return false;
                }
                pauseload.letstore_list = 1;

                //暂停滚动载入新内容
                scrollload.letstore_list = 0;

                var $tmp_this_card_more = $(this);

                var tmp_page = $(this).data("page") ? $(this).data("page") : 1;

                if (tmp_page <= 1) {
                    tmp_pointarr = [];
                    map.clearOverlays(); //清空地图上的打点
                    if (ajax_letstore_list) {
                        ajax_letstore_list.abort();
                    }
                    $(".list_store").html("");
                }

                var tmp_params = {
                    "page": tmp_page,
                    "province": $(".filterstore_form [name=province]").val(),
                    "city": $(".filterstore_form [name=city]").val(),
                    "area": $(".filterstore_form [name=area]").val(),
                    "keyword": $(".filterstore_form [name=keyword]").val()
                }

                //console.log( tmp_params );

                getlist(tmp_page);
                // 	  ajax_letstore_list = $.ajax({
                // 		type: "GET",
                // 		datatype: "json",
                // 		url: "./demo/json/store_list.json",
                // 		data: tmp_params,
                // 		beforeSend: function(){
                // 		  $tmp_this_card_more.html( "正在载入…" );
                // 		},
                // 		success: function(data){//typeof
                // 		  if( typeof data != "object" ) {
                // 			data = $.parseJSON(data);
                // 		  }
                //
                // 		  if( data.status == 1 ) {
                // 				var $tmp_html = $("<div/>");
                // 				var fetch_data = data.data;
                // 				//没有更多内容了
                // 				if( fetch_data.length == 0 ) {
                // 					if( tmp_page == 1 ){
                // 					$tmp_this_card_more.hide();
                // 					$("#letstore_main .list_store").html("<div class=\"nothing\"><i class=\"material-icons big\">&#xe549;</i><div>没找到考点</div></div>");
                // 					}
                // 					$tmp_this_card_more.html( "没有更多内容了" ).addClass("nomore");
                // 					pauseload.letstore_list = 0;
                // 					return false;
                // 				}
                //
                // 				for(var i = 0; i < fetch_data.length; i++) {
                // 					var $tmp_item = $("#tmp_item_letstore .item_letstore").clone();
                //
                // 					$tmp_item.data("storeid", fetch_data[i].storeid);
                // 					$tmp_item.data("lat", fetch_data[i].lat);
                // 					$tmp_item.data("lng", fetch_data[i].lng);
                // 					//$tmp_item.data("cover", fetch_data[i].cover);
                //
                // 					$tmp_item.find(".btn_readmore").attr("href", "./store_view.html?storeid=" + fetch_data[i].storeid);
                //
                // 					$tmp_item.find(".name span").text( fetch_data[i].name );
                // 					$tmp_item.data("name", fetch_data[i].name);
                //
                // 					$tmp_item.find(".address span").text( fetch_data[i].address );
                // 					$tmp_item.data("address", fetch_data[i].address);
                //
                // 					$tmp_item.find(".phone span").text( fetch_data[i].phone );
                // 					$tmp_item.data("phone", fetch_data[i].phone);
                //
                // 					if( fetch_data[i].phone2 ){
                // 					$tmp_item.find(".phone").clone().appendTo( $tmp_item.find(".phone_wrap") ).find("span").text( fetch_data[i].phone2 );
                // 					$tmp_item.data("phone2", fetch_data[i].phone2);
                // 					}
                // 					if( fetch_data[i].type ){
                // 					$tmp_item.find(".vipmark").text( fetch_data[i].type );
                // 					} else {
                // 					$tmp_item.find(".vipmark").remove();
                // 					}
                // 					$tmp_html.append( $tmp_item );
                //
                // 					fun_placemarker( $tmp_item, false );//在地图上打点
                // 					if( i + 1 == fetch_data.length ){//自动缩放地图视口
                // 					var view = map.getViewport(eval(tmp_pointarr));
                // 					var mapZoom = view.zoom;
                // 					var centerPoint = view.center;
                // 					map.centerAndZoom(centerPoint, mapZoom);
                // 					}
                //
                // 				}
                //
                // 				$tmp_html.find(".item_letstore").appendTo( ".list_store" );
                //
                // 				//允许滚动载入新内容
                // 				scrollload.letstore_list = 1;
                //
                // 				//页数累加
                // 				tmp_page++;
                // 				$tmp_this_card_more.data( "page", tmp_page );
                // 				lazy();
                // 				$tmp_this_card_more.html( "点击载入更多" );
                //
                // 				pauseload.letstore_list = 0;
                //
                // 		  }
                // 		  //载入失败
                // 		  if( data.status == 0 ) {
                // 			$tmp_this_card_more.html( "载入失败，点击重试" );
                // 			$.fn.winktips("载入失败 ( >﹏<。)");
                // 			pauseload.letstore_list = 0;
                // 		  }
                // 		  return false;
                //
                // 		},
                // 		error: function(){
                // 		  if(status !== "abort"){
                // 			$tmp_this_card_more.html( "载入失败，点击重试" );
                // 			$.fn.winktips("载入失败 （/TДT)/");
                // 			pauseload.letstore_list = 0;
                // 		  }
                // 		}
                //
                // 	  });

            });
            $("#storemap_list .main_more").data("page", 1).click();

            //滚动载入新内容
            $("#storemap_list").scroll(function() {
                if (scrollload.letstore_list) {
                    scrollLoad($("#storemap_list .main_more"));
                }
            });


            function getlist(tmp_page) {

                //console.log(tmp_page)
                var $tmp_this_card_more = $("#storemap_main .main_more");
                var tmp_province = ($("#province").val() != "省份") ? $("#province").val() : "";
                var tmp_city = ($("#city").val() != "地级市") ? $("#city").val() : "";
                var tmp_area = ($("#area").val() != "市、县级市、县") ? $("#area").val() : "";
                var search = $("#search_input").val();

                httpPost(GET_EXAMINATION_POINT_LIST, {
                    pageSize: 10,
                    pageNum: tmp_page,
                    provinceName: tmp_province,
                    cityName: tmp_city,
                    areaName: tmp_area,
                    search: search
                }, function(results) {
                    //console.log(results)
                    var $tmp_html = $("<div/>");
                    var fetch_data = results;
                    //console.log(results)
                    //没有更多内容了
                    if (fetch_data.length == 0) {

                        if (tmp_page == 1) {
                            $tmp_this_card_more.hide();
                            $("#storemap_main .list_store").html("<div class=\"nothing\"><i class=\"material-icons big\">&#xe549;</i><div>没找到考点</div></div>");
                        }
                        $tmp_this_card_more.html("没有更多内容了").addClass("nomore");
                        pauseload.letstore_list = 0;
                        return false;
                    }
                    //console.log(fetch_data.length)
                    for (var i = 0; i < fetch_data.length; i++) {
                        var $tmp_item = $("#tmp_item_letstore .item_letstore").clone();

                        $tmp_item.data("storeid", fetch_data[i].id);
                        $tmp_item.data("lat", fetch_data[i].latitude);
                        $tmp_item.data("lng", fetch_data[i].longitude);
                        //$tmp_item.data("cover", fetch_data[i].cover);

                        $tmp_item.find(".btn_readmore").attr("href", "./kaodian_view.html?id=" + fetch_data[i].id);

                        $tmp_item.find(".name span").text(fetch_data[i].companyName);
                        $tmp_item.data("name", fetch_data[i].companyName);

                        var tmp_com = fetch_data[i].companyAddress.split("&&")[1];
                        var tmp_p = fetch_data[i].province.name;
                        var tmp_c = fetch_data[i].city.name;
                        var tmp_a = fetch_data[i].area ? fetch_data[i].area.name : '';

                        $tmp_item.find(".address span").text(tmp_p + tmp_c + tmp_a + tmp_com);

                        //$tmp_item.data("address", fetch_data[i].companyAddress);
                        $tmp_item.data("address", tmp_p + tmp_c + tmp_a + tmp_com);

                        //$tmp_item.find(".phone span").text(fetch_data[i].chargePhone);
                        //$tmp_item.data("phone", fetch_data[i].chargePhone);

                        if (fetch_data[i].examinationPhone) {
                            $tmp_item.find(".phone span").text(fetch_data[i].examinationPhone);
                            $tmp_item.data("phone2", fetch_data[i].examinationPhone);
                        }
                        // if (fetch_data[i].type) {
                        //     $tmp_item.find(".vipmark").text(fetch_data[i].type);
                        // } else {
                        //     $tmp_item.find(".vipmark").remove();
                        // }
                        $tmp_html.append($tmp_item);

                        fun_placemarker($tmp_item, false); //在地图上打点
                        if (i + 1 == fetch_data.length) { //自动缩放地图视口
                            var view = map.getViewport(eval(tmp_pointarr));
                            var mapZoom = view.zoom;
                            var centerPoint = view.center;
                            map.centerAndZoom(centerPoint, mapZoom);
                        }

                    }

                    $tmp_html.find(".item_letstore").appendTo(".list_store");

                    //允许滚动载入新内容
                    scrollload.letstore_list = 1;

                    //页数累加
                    tmp_page++;
                    $tmp_this_card_more.data("page", tmp_page);
                    lazy();
                    $tmp_this_card_more.html("点击载入更多");

                    pauseload.letstore_list = 0;
                });
            }
        </script>



        <!------------------------------------ 主体分割 -------------------------------->

        <!------------------------------------ 主体分割 -------------------------------->




    </div>
    <!-- 主体 结束 -->


</body>

    </div>
    <!-- 主体 结束 -->


</body>

</html>
